package name.fordj.glutil.index;

import ca.odell.glazedlists.impl.beans.BeanProperty;

public class BeanPropertyKeyMaker<T, R> implements KeyMaker<T, R> {
    private final String id;
    private final BeanProperty<T> beanProperty;

    public BeanPropertyKeyMaker(String id, Class<T> clazz, String property) {
        this.id = id;
        beanProperty = new BeanProperty<T>(clazz, property, true, false);
    }

    public String getId() {
        return id;
    }

    public R makeKey(T obj) {
        return (R) beanProperty.get(obj);
    }
}
